<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>00_引入</title>
</head>
<body>
<button>测试1</button>
<button>测试2</button>
<button>测试3</button>
<!-- 
    需求：点击某个按钮，提示 点击的是第n个按钮
 -->
 <script>
 var oBtns = document.getElementsByTagName('button')
 // 遍历添加监听
 for(var i = 0; i < oBtns.length; i++) {
     oBtns[i].onclick = (function(i) {
         return function() {
            alert(i + 1)
         }
     })(i)
 }
 </script>
</body>
</html>